/***************************************************
Class: WorldObject
Includes: stdafx.h, Mesh.h
Editors: Gindi
Existing Issues: None
Description: Class for WorldObjects such as env. and unit objects. Almost 
every 3D object rendered, with the exception of the projectiles, are of 
type WorldObject. Refer to the .cpp file(s) for 
more information on the function of the functions... :)
***************************************************/
#pragma once
#include "MiscObject.h"
#include "stdafx.h"
#include "Mesh.h"
#include "WorldObjectStates.h"
//#include "ProjObject.h"

class WorldObject {
public: // public functions
	WorldObject() {}
	WorldObject(string mFile) { modelFile = mFile; }
	~WorldObject() { Release(); }
	void Release();
	bool Initialize(LPDIRECT3DDEVICE9 pDevice);
	bool InitializeMesh(LPDIRECT3DDEVICE9 pDevice);
	void Update(float elapsedTime);
	void Update(bool TDView, float deltaX, float deltaY, float elapsedTime);
	void Render(LPDIRECT3DDEVICE9 pDevice);
	
	void UpdateLookDirection(float elapsedTime);
	void ConstrictDirectionPoint();
private: // private functions
	// initializors
	void InitializeUnitInfo();
	void InitializePhysicsInfo();

	// movement-related functions
	void MoveRelativeToMouse(float deltaX, float deltaY, float elapsedTime);
	void MoveRelativeToMouseX(float deltaX, float elapsedTime);
	void UpdateVelocityVector(float elapsedTime);
	void UpdateMeshRotation();
	void UpdateMovement(float elapsedTime);
	
	// weapon-related functions
	void UpdateWeaponCooldown(float elapsedTime);

	void UpdateHpRegen(float elapsedTime);

public: // public variables
	Mesh			mesh;			// mesh
	MeshInstance	meshInst;		// mesh instance (has world transformation such as position, rotation, and scale)
	int				key;			// may make obsolete in the future
	int				value;			// the value of the object if destroyed (destroyer gains points)
	float			distToCam;
	float			health;
	float			hpRegen;
	float			hpRegenTimer;
	float			maxHealth;
	bool			destructable;
	string			alignment;		// "Player", "Ally", "Enemy", "Neutral"
	string			dataFile;		// data file of this object that stores its specific information (physics info, weapons, etc.)
	string			modelFile;		// model (.x) file for the object mesh
	string			name;			// name of the object (e.g. "Lancaster")
	string			ruinFile;
	UnitInfo		unitInfo;		// unit information (struct: see stdafx.h for more information)
	PhysicsInfo		physicsInfo;	// physics information (struct: see stdafx.h for more information)
	list<WeaponInfo> weapons;		// list of weapons this object carries (typically, only units have weapons)
	ITERATOR(WeaponInfo) weaIter;	// weapon-list iterator

	// lari
	WorldObject*	m_targetUnit;		// holds target information for a unit
	MiscObject*		m_targetNonUnit;	// holds target info for a waypoint
	WorldObjectState m_state;			// holds unit state info 
	// end: lari
	list<WorldObject*> unitsTargeting;	// holds a list of pointers to units that are targeting this unit
	ITERATOR(WorldObject*) uTargetIter;
};
